package logic

import (
	"context"
	"hzjt-oam/rpc/sys/model"
	"time"

	"hzjt-oam/rpc/sys/internal/svc"
	"hzjt-oam/rpc/sys/pb"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateSysUserLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUpdateSysUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateSysUserLogic {
	return &UpdateSysUserLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UpdateSysUserLogic) UpdateSysUser(in *pb.UpdateSysUserReq) (*pb.UpdateSysUserResp, error) {
	_ = l.svcCtx.UserModel.Update(l.ctx, &model.SysUser{
		Name:           in.Name,
		NickName:       in.NickName,
		Avatar:         in.Avatar,
		Password:       in.Password,
		Salt:           in.Salt,
		Email:          in.Email,
		Mobile:         in.Mobile,
		Status:         in.Status,
		DeptId:         in.DeptId,
		CreateBy:       in.CreateBy,
		LastUpdateBy:   in.LastUpdateBy,
		LastUpdateTime: time.Now().Unix(),
		DelFlag:        in.DelFlag,
		RoleId:         in.RoleId,
	})

	return &pb.UpdateSysUserResp{}, nil
}
